package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import com.itheima.service.impl.UserServiceImpl;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class UserController extends BaseServlet{

    @Test
    public void findAll(){
        //加载spring配置文件,获的ioc容器
       ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
       //通过ioc容器获得对象
        UserService userService = context.getBean(UserService.class);
        //调用业务层的findAll方法
        List<User> userList = userService.findAll();

        for (User user : userList) {
            System.out.println(user);
        }
    }
}
